\usepackage{graphicx}
\usepackage{indentfirst}
\usepackage[usenames,dvipsnames]{color}
\usepackage{fancyvrb} % for verbatim
\usepackage{fancyhdr}
\usepackage{listings}
\usepackage[sf]{titlesec}
\usepackage{titletoc}
\usepackage[boldfont,slantfont,CJKnumber]{xeCJK}
\usepackage{xcolor} % 使用颜色宏包
\usepackage{color}
\usepackage{amsmath, amsfonts, epsfig, xspace}
\usepackage{algorithm,algorithmic}
\usepackage[normal,tight,center]{subfigure}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{array}
\usepackage{multicol}
\usepackage{colortbl}
\usepackage{caption}
 
\definecolor{steelblue}{rgb}{.275,.51,.71}
\definecolor{lpink}{rgb}{.991,.711,.754}
\definecolor{mygray}{gray}{0.92}
\definecolor{darkblue}{rgb}{0,0,.5}
\definecolor{darkgreen}{rgb}{0,.39,0}
\definecolor{hgray}{gray}{.5}
\definecolor{lgray}{gray}{.8}
 
\usepackage[colorlinks=true,urlcolor=blue,linkcolor=blue]{hyperref} % for links and anchors
 
\setCJKmainfont[BoldFont=Adobe Heiti Std]{Adobe Song Std} % 设置默认的中文字体
\setCJKfamilyfont{kai}{Adobe Kaiti Std}
 
\newcommand{\kai}{\CJKfamily{kai}}

\setCJKmainfont[BoldFont={SimHei},ItalicFont={KaiTi}]{SimSun}
\setCJKsansfont{SimHei}
\setCJKmonofont{FangSong}
\setCJKfamilyfont{zhsong}{SimSun}
\setCJKfamilyfont{zhhei}{SimHei}
\setCJKfamilyfont{zhkai}{KaiTi}
\setCJKfamilyfont{zhfs}{FangSong}


\newcommand{\songti}{\CJKfamily{zhsong}} % 宋体
\newcommand{\heiti}{\CJKfamily{zhhei}}   % 黑体
\newcommand{\kaishu}{\CJKfamily{zhkai}}  % 楷书
\newcommand{\fangsong}{\CJKfamily{zhfs}} % 仿宋
\newcommand{\lishu}{\CJKfamily{zhli}}    % 隶书
\newcommand{\youyuan}{\CJKfamily{zhyou}} % 幼圆


\newcommand{\sectionname}{第\CJKnumber{\thesection}章}
\newcommand{\myheader}[1]{\textcolor{darkblue}{#1}}
 
\def\projectName{项目:smdk2410-drivers}%项目名称
\renewcommand\contentsname{目录}
 
\special{ pdf: bgcolor [ 1.00 0.98 0.95 ] }
 
\linespread{1.382}
 
\pagestyle{fancy}
 
\makeatletter
  \fancyhf{}
  \lhead{\textcolor{hgray}\@title}
  \rhead{\textcolor{hgray}\leftmark}
\makeatother
 
\makeatletter
\renewcommand{\maketitle}{
\begin{titlepage}%
\let\footnotesize\small
    \let\footnoterule\relax
    \parindent \z@
    \reset@font
    \vskip 10\p@
    \hbox{\mbox{%
        \hspace{2pt}%
        \fbox{\includegraphics[width=6em]{./led.jpg}}%
        \hspace{2pt}
        }%
     \vrule depth 0.8\textheight%这是那条线
     \mbox{\hspace{0.5em}}
     \vtop{% %%%%%%%%%%%%%%%%%%
        \vskip 5\p@
        \begin{flushleft}
          \Large \projectName \par
        \end{flushleft}
        \vskip 60\p@
        \begin{flushleft}
        %\textcolor{steelblue}{ \fontsize{36}{20pt} \bfseries \kaishu \@title }\par
        \textcolor{steelblue}{ \fontsize{36}{20pt} \bfseries \kaishu smdk2410-led\\\vskip 15\p@\rightline{驱动总结}}\par
        \end{flushleft}
 
      }
     }
     \rightline{By \@author}
 
  \end{titlepage}%
}
 
\makeatother
 
\titleformat{\section}[hang]{\LARGE\sf\kaishu}
            {\myheader\sectionname}
            {1em}
            {\myheader}[\color{steelblue}{\titlerule}]
 
\titleformat{\subsection}[hang]{\Large\sf\kaishu}
            {\myheader\thesubsection}
            {1em}
            {\myheader}
\titleformat{\subsubsection}[hang]{\large\sf\kaishu}
            {\myheader\thesubsubsection}
            {1em}
            {\myheader}
 
\titlecontents{section}
              [2em]{\large\sf\kaishu\addvspace{-0.1em}}
              {\thecontentslabel\quad}
%%            {\hspace*{-2.3em}}
              {}
              {\titlerule*[0.8pc]{.}\contentspage}
\titlecontents{subsection}
              [4em]{\small\addvspace{-0.2em}}
              {\thecontentslabel\quad}
%%            {\hspace*{-2.3em}}
              {}
              {\titlerule*[0.8pc]{.}\contentspage}
\titlecontents{subsubsection}
              [6em]{\small\addvspace{-0.2em}}
              {\thecontentslabel\quad}
%%            {\hspace*{-2.3em}}
              {}
              {\titlerule*[0.8pc]{.}\contentspage}

\lstset{
         basicstyle=\footnotesize\ttfamily, % Standardschrift
         numbers=left,               % Ort der Zeilennummern
         numberstyle=\tiny,          % Stil der Zeilennummern
         %stepnumber=2,               % Abstand zwischen den Zeilennummern
         numbersep=5pt,              % Abstand der Nummern zum Text
         tabsize=2,                  % Groesse von Tabs
         extendedchars=true,         %
         breaklines=true,            % Zeilen werden Umgebrochen
         keywordstyle=\color{red},
         frame=b,         
         stringstyle=\color{white}\ttfamily, % Farbe der String
         showspaces=false,           % Leerzeichen anzeigen ?
         showtabs=false,             % Tabs anzeigen ?
         xleftmargin=17pt,
         framexleftmargin=17pt,
         framexrightmargin=5pt,
         framexbottommargin=4pt,
         backgroundcolor=\color{lightgray},
         showstringspaces=false      % Leerzeichen in Strings anzeigen ?       
}
\renewcommand{\lstlistingname}{CODE}
\lstloadlanguages{% Check Dokumentation for further languages ...
         %[Visual]Basic
         %Pascal
         C
         %C++
         %XML
         %HTML
         %Java
}

\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\colorbox[cmyk]{0.43, 0.35, 0.35,0.01}{\parbox{\textwidth}{#1#2#3}}}
\captionsetup[lstlisting]{format=listing,justification=raggedright,labelfont=white,textfont=white, singlelinecheck=false, margin=0pt, font={sf,bf,footnotesize}}

